var n;
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.GuideCtrl = undefined;
var BundleConfig = require("AA_BundleConfig");
var SingletonManager = require("AA_SingletonManager");
var ResLoader = require("AA_ResLoader");
var ResUtil = require("AA_ResUtil");
var GuideMask = require("AA_GuideMask");
var GuideShou = require("AA_GuideShou");
var h = function (e) {
  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.shouArray = [];
    return t;
  }
  __extends(t, e);
  t.prototype.ShowOneShou = function (e) {
    return __awaiter(this, undefined, undefined, function () {
      var t;
      var o;
      var n;
      var i;
      return __generator(this, function (a) {
        switch (a.label) {
          case 0:
            t = this;
            o = function () {
              t.RecycleOneShou(n);
              e.parent.off(cc.Node.EventType.TOUCH_START, o);
            };
            if (this.shouArray.length > 0) {
              n = this.shouArray.shift();
              return [3, 4];
            } else {
              return [3, 1];
            }
          case 1:
            if (this.guideShowPfb) {
              return [3, 3];
            } else {
              i = this;
              return [4, ResLoader.default.loadRes(BundleConfig.BundleNames.Common, "common/prefab/GuideShou", cc.Prefab)];
            }
          case 2:
            i.guideShowPfb = a.sent();
            a.label = 3;
          case 3:
            n = cc.instantiate(this.guideShowPfb);
            a.label = 4;
          case 4:
            n.parent = e.parent;
            n.stopAllActions();
            n.active = true;
            n.setPosition(e.x, e.y);
            e.isWillClickClose && e.parent.on(cc.Node.EventType.TOUCH_START, o);
            e.getFingerCallBack && e.getFingerCallBack(n);
            n.getComponent(GuideShou.default).StartSet(e.isWillClickClose);
            return [2];
        }
      });
    });
  };
  t.prototype.RecycleOneShou = function (e) {
    e.active = false;
    e.removeFromParent(false);
    this.shouArray.push(e);
  };
  t.prototype.cleanGuide = function () {
    if (this.guideMask) {
      this.guideMask.destroy();
      this.guideMask = null;
    }
  };
  t.prototype.ShowGuide = function (e) {
    return __awaiter(this, undefined, undefined, function () {
      var t;
      var o;
      var n;
      return __generator(this, function (i) {
        switch (i.label) {
          case 0:
            if (this.guideMask) {
              return [3, 2];
            } else {
              return [4, ResLoader.default.loadRes(BundleConfig.BundleNames.Common, "common/prefab/GuideMask", cc.Prefab)];
            }
          case 1:
            t = i.sent();
            o = cc.director.getScene().getChildByName("Canvas");
            (n = ResUtil.ResUtil.instantiate(t)).parent = o;
            this.guideMask = n.getComponent(GuideMask.default);
            n.setPosition(0, 0);
            i.label = 2;
          case 2:
            this.guideMask.node.zIndex = 1e3;
            this.guideMask.node.active = true;
            this.guideMask.StartSet(e);
            return [2];
        }
      });
    });
  };
  t.prototype.ShowGuideMaskKuang = function (e, t, n) {
    undefined === n && (n = 0);
    var i = t.convertToWorldSpaceAR(cc.v2(0, 0));
    var a = cc.size(1e3, 1700);
    var r = 500 + (t.height - 1334) / 2;
    0 != n && (r = n);
    exports.GuideCtrl.ShowGuide({
      wPos: i,
      size: a,
      alwaysShow: true,
      sayNodePos: cc.v2(0, r),
      callBack: null,
      sayStr: e,
      isHideBtn: true,
      noMaskTween: true
    });
  };
  return t;
}(SingletonManager.SingletonMgr);
exports.GuideCtrl = h.getInstance();